import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../views/Home.vue';
// import comA from '../views/comA.vue';
// import comB from '../views/comB.vue';

Vue.use(VueRouter);

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home,
        // redirect: '/about',  // 重定向
        // redirect: { name: 'About' },
        // redirect: (to) => {
        //     return '/about';
        // },
        alias: '/b',  // 别名
    },
    {
        path: '/about',
        name: 'About',
        component: () => import('../views/About.vue'),
        // components: {
        //     default: () => import('../views/About.vue'),
        //     // a: comA,
        //     // b: comB,
        //     a: () => import('../views/comA.vue'),
        //     b: () => import('../views/comB.vue'),
        // },
    },
];

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes,
});

export default router;
